/*
-----------------------------------------------------------------------------
This source file is part of SapphireEngine

SapphireEngine is a Framework for Turn Based Strategy games.
For more information see http://code.google.com/p/sapphire-engine/

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt.

-----------------------------------------------------------------------------
*/
#ifndef _SCREENS_H
#define _SCREENS_H

#include "SapphirePrerequisites.h"
//#include "GUI/GUIManager.h"
#include <CEGUI/CEGUI.h>
#include <OIS/OIS.h>
#include <OgreCEGUIRenderer.h>

#include <list>

namespace SapphireEngine
{
	namespace GUI
	{
		class Screen
		{
		public:
			Screen():mContinue(true),mNextScreenName("")
			{}
			virtual ~Screen()
			{
				unSubscribeEvents();
			}
			Screen(CEGUI::String  layoutFile):mContinue(true)
			{
				setLayoutFile(layoutFile);
			}
			void setLayoutFile(CEGUI::String layoutFile)
			{
				mLayout = getWindowManager()->loadWindowLayout(layoutFile);
			}
			void showLayout()
			{
				getSystem()->setGUISheet(mLayout);
				subscribeEvents();

			}
			virtual bool update(const FrameEvent &evt)
			{
				return mContinue;
			}
			// Events
			virtual void unSubscribeEvents()
			{
				while(!mEventConnections.empty())
				{
					mEventConnections.front()->disconnect();
					mEventConnections.pop_front();
				}
			}
			virtual void subscribeEvents(){}
			// MouseListener
			virtual bool mouseMoved(const OIS::MouseEvent &arg){return true;}
			virtual bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id){return true;}
			virtual bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id){return true;}
			// KeyListener
			virtual bool keyPressed(const OIS::KeyEvent &arg){return true;}
			virtual bool keyReleased(const OIS::KeyEvent &arg){return true;}

			virtual Ogre::String getNextScreenName(){return mNextScreenName;}
			virtual void setNextScreenName(Ogre::String name){mNextScreenName=name;}
		protected:
			Window* mLayout;
			bool mContinue;
			Ogre::String mNextScreenName;

			std::list<CEGUI::Event::Connection> mEventConnections;
		};

	}
}

//SubClass Screens
#include "GUI/LoadingScreen.h"
//#include "GUI/GameScreen.h"
#include "GUI/MainMenuScreen.h"
//#include "GUI/TestScreen.h"

#endif